import path from 'node:path';

import { defineConfig } from '@vben/vite-config';

import ElementPlus from 'unplugin-element-plus/vite';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      plugins: [
        ElementPlus({
          format: 'esm',
          ignoreComponents: ['AutoResizer'],
        }),
      ],
      resolve: {
        alias: {
          '@': path.resolve(import.meta.dirname, './src'),
        },
      },
      server: {
        proxy: {
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, '/dsc-api'),
            // 项目的接口baseurl
            // target: 'http://172.21.252.218:8080/mtde-api',
            target: 'http://119.45.181.127',
            ws: true,
          },
        },
      },
    },
  };
});
